package cz.tomasdvorak.cars.dto;

import java.io.Serializable;
import java.util.Date;

public class Expense implements Serializable {
    private int id;
    private ExpenseType type;
    private Date date;
    private int mileage;
    private int quantity;
    private int price;
    private int personId;
    private int vehicleId;

    public Expense(int id, ExpenseType type, Date date, int mileage, int quantity, int price,
                   int personId, int vehicleId) {
        this.id = id;
        this.type = type;
        this.date = date != null ? new Date(date.getTime()) : null;
        this.mileage = mileage;
        this.quantity = quantity;
        this.price = price;
        this.personId = personId;
        this.vehicleId = vehicleId;
    }

    public Expense() {
        this.id = -1;
        this.date = new Date();
        this.personId = -1;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public ExpenseType getType() {
        return type;
    }

    public void setType(ExpenseType type) {
        this.type = type;
    }

    public Date getDate() {
        return date != null? new Date(date.getTime()) : null;
    }

    public void setDate(Date date) {
        this.date = date != null? new Date(date.getTime()) : null;
    }

    public int getMileage() {
        return mileage;
    }

    public void setMileage(int mileage) {
        this.mileage = mileage;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getPersonId() {
        return personId;
    }

    public void setPersonId(int personId) {
        this.personId = personId;
    }

    public int getVehicleId() {
        return vehicleId;
    }

    public void setVehicleId(int vehicleId) {
        this.vehicleId = vehicleId;
    }

    public boolean isNew() {
        return id == -1;
    }
}
